package com.example.lotapp.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.text.TextUtils;

public class DateUtils {
	public static Date stringToDate(String dateString, String formatString, Date defValue) {
		if (TextUtils.isEmpty(dateString) || TextUtils.isEmpty(formatString)) {
			return defValue;
		}
		DateFormat dateFormat = new SimpleDateFormat(formatString, Locale.US);
		try {
			Date date = dateFormat.parse(dateString);
			return date;
		} catch (ParseException e) {
			return defValue;
		}
	}
}
